package com.kingsoft.labs.tangram.domain;

import org.json.JSONObject;

import com.kingsoft.labs.tangram.util.io.JSONHelper;
import com.kingsoft.labs.tangram.util.io.Serializable;

public class Result implements Serializable{
	public int returnCode = 0;
	
	public void setAllFlags(boolean b) {
		if (b) {
			returnCode = 0;
		} else {
			returnCode = ~0;
		}
	}
	
	public boolean isAllSuccessful() {
		return 0 == returnCode;
	}

	@Override
	public String serialize() {
		return JSONHelper.serializeResult(this).toString();
	}

	public static Result deserialize(String jsonStr) throws Exception {
		JSONObject json = new JSONObject(jsonStr);
		return JSONHelper.deserializeResult(json);
	}
}
